// 动画样式文件

// 基础动画关键帧
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-30px);
  }
}

@keyframes slideOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(30px);
  }
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-30px);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
  }
  to {
    transform: scale(1);
  }
}

@keyframes zoomOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: scale(0.3);
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -30px, 0);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -15px, 0);
  }
  90% {
    transform: translate3d(0, -4px, 0);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-10px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(10px);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes heartbeat {
  0% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.3);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.3);
  }
  70% {
    transform: scale(1);
  }
}

@keyframes swing {
  20% {
    transform: rotate(15deg);
  }
  40% {
    transform: rotate(-10deg);
  }
  60% {
    transform: rotate(5deg);
  }
  80% {
    transform: rotate(-5deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

@keyframes wobble {
  0% {
    transform: translateX(0%);
  }
  15% {
    transform: translateX(-25%) rotate(-5deg);
  }
  30% {
    transform: translateX(20%) rotate(3deg);
  }
  45% {
    transform: translateX(-15%) rotate(-3deg);
  }
  60% {
    transform: translateX(10%) rotate(2deg);
  }
  75% {
    transform: translateX(-5%) rotate(-1deg);
  }
  100% {
    transform: translateX(0%);
  }
}

@keyframes flip {
  from {
    transform: perspective(400px) rotateY(-1turn);
    animation-timing-function: ease-out;
  }
  40% {
    transform: perspective(400px) translateZ(150px) rotateY(-190deg);
    animation-timing-function: ease-out;
  }
  50% {
    transform: perspective(400px) translateZ(150px) rotateY(-170deg);
    animation-timing-function: ease-in;
  }
  80% {
    transform: perspective(400px) scale(0.95);
    animation-timing-function: ease-in;
  }
  100% {
    transform: perspective(400px);
    animation-timing-function: ease-in;
  }
}

@keyframes rotateIn {
  from {
    transform-origin: center;
    transform: rotate(-200deg);
    opacity: 0;
  }
  100% {
    transform-origin: center;
    transform: rotate(0);
    opacity: 1;
  }
}

@keyframes rotateOut {
  from {
    transform-origin: center;
    opacity: 1;
  }
  100% {
    transform-origin: center;
    transform: rotate(200deg);
    opacity: 0;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba($color-primary, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba($color-primary, 0.8), 0 0 30px rgba($color-primary, 0.6);
  }
}

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

// 动画类
.animate {
  animation-duration: 0.3s;
  animation-fill-mode: both;
  
  // 淡入淡出
  &.fade-in {
    animation-name: fadeIn;
  }
  
  &.fade-out {
    animation-name: fadeOut;
  }
  
  // 滑入滑出
  &.slide-in-up {
    animation-name: slideInUp;
  }
  
  &.slide-in-down {
    animation-name: slideInDown;
  }
  
  &.slide-in-left {
    animation-name: slideInLeft;
  }
  
  &.slide-in-right {
    animation-name: slideInRight;
  }
  
  &.slide-out-up {
    animation-name: slideOutUp;
  }
  
  &.slide-out-down {
    animation-name: slideOutDown;
  }
  
  &.slide-out-left {
    animation-name: slideOutLeft;
  }
  
  &.slide-out-right {
    animation-name: slideOutRight;
  }
  
  // 缩放
  &.scale-in {
    animation-name: scaleIn;
  }
  
  &.scale-out {
    animation-name: scaleOut;
  }
  
  &.zoom-in {
    animation-name: zoomIn;
  }
  
  &.zoom-out {
    animation-name: zoomOut;
  }
  
  // 弹跳和摇摆
  &.bounce {
    animation-name: bounce;
    animation-duration: 1s;
  }
  
  &.shake {
    animation-name: shake;
    animation-duration: 0.8s;
  }
  
  &.pulse {
    animation-name: pulse;
    animation-duration: 1s;
    animation-iteration-count: infinite;
  }
  
  &.heartbeat {
    animation-name: heartbeat;
    animation-duration: 1.3s;
    animation-iteration-count: infinite;
  }
  
  &.swing {
    animation-name: swing;
    animation-duration: 1s;
  }
  
  &.wobble {
    animation-name: wobble;
    animation-duration: 1s;
  }
  
  // 翻转和旋转
  &.flip {
    animation-name: flip;
    animation-duration: 0.6s;
  }
  
  &.rotate-in {
    animation-name: rotateIn;
    animation-duration: 0.6s;
  }
  
  &.rotate-out {
    animation-name: rotateOut;
    animation-duration: 0.6s;
  }
  
  &.spin {
    animation-name: spin;
    animation-duration: 1s;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
  }
  
  // 浮动和发光
  &.float {
    animation-name: float;
    animation-duration: 3s;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
  }
  
  &.glow {
    animation-name: glow;
    animation-duration: 2s;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
  }
  
  // 打字效果
  &.typing {
    animation-name: typing;
    animation-duration: 3s;
    animation-timing-function: steps(40, end);
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid;
    
    &.blink {
      animation: typing 3s steps(40, end), blink 0.75s step-end infinite;
    }
  }
}

// 动画延迟
.animate-delay-1 {
  animation-delay: 0.1s;
}

.animate-delay-2 {
  animation-delay: 0.2s;
}

.animate-delay-3 {
  animation-delay: 0.3s;
}

.animate-delay-4 {
  animation-delay: 0.4s;
}

.animate-delay-5 {
  animation-delay: 0.5s;
}

// 动画持续时间
.animate-fast {
  animation-duration: 0.15s;
}

.animate-faster {
  animation-duration: 0.1s;
}

.animate-slow {
  animation-duration: 0.6s;
}

.animate-slower {
  animation-duration: 1s;
}

// 无限循环动画
.animate-infinite {
  animation-iteration-count: infinite;
}

// 动画暂停
.animate-paused {
  animation-play-state: paused;
}

// 悬停时触发动画
.hover-animate {
  &:hover {
    .animate {
      animation-play-state: running;
    }
  }
}

// 页面切换动画
.page-enter-active,
.page-leave-active {
  transition: all 0.3s ease;
}

.page-enter-from {
  opacity: 0;
  transform: translateX(20px);
}

.page-leave-to {
  opacity: 0;
  transform: translateX(-20px);
}

// 路由切换动画
.route-enter-active {
  animation: slideInRight 0.3s ease;
}

.route-leave-active {
  animation: slideOutLeft 0.3s ease;
}

// 模态框动画
.modal-enter-active {
  animation: scaleIn 0.3s ease;
}

.modal-leave-active {
  animation: scaleOut 0.3s ease;
}

// 抽屉动画
.drawer-enter-active {
  animation: slideInRight 0.3s ease;
}

.drawer-leave-active {
  animation: slideOutRight 0.3s ease;
}

// 下拉菜单动画
.dropdown-enter-active {
  animation: slideInDown 0.2s ease;
}

.dropdown-leave-active {
  animation: slideOutUp 0.2s ease;
}

// 工具提示动画
.tooltip-enter-active {
  animation: fadeIn 0.15s ease;
}

.tooltip-leave-active {
  animation: fadeOut 0.15s ease;
}

// 消息提示动画
.message-enter-active {
  animation: slideInDown 0.3s ease;
}

.message-leave-active {
  animation: slideOutUp 0.3s ease;
}

// 通知动画
.notification-enter-active {
  animation: slideInRight 0.3s ease;
}

.notification-leave-active {
  animation: slideOutRight 0.3s ease;
}

// 加载动画
.loading-enter-active {
  animation: fadeIn 0.2s ease;
}

.loading-leave-active {
  animation: fadeOut 0.2s ease;
}

// 列表项动画
.list-enter-active {
  animation: slideInUp 0.3s ease;
}

.list-leave-active {
  animation: slideOutDown 0.3s ease;
  position: absolute;
  width: 100%;
}

.list-move {
  transition: transform 0.3s ease;
}

// 卡片悬停动画
.card-hover {
  transition: all 0.3s ease;
  
  &:hover {
    transform: translateY(-4px);
    box-shadow: $box-shadow-lg;
  }
}

// 按钮点击动画
.btn-click {
  transition: all 0.1s ease;
  
  &:active {
    transform: scale(0.95);
  }
}

// 图片加载动画
.img-loading {
  background: linear-gradient(90deg, $skeleton-color 25%, $skeleton-to-color 50%, $skeleton-color 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

// 文字闪烁动画
.text-blink {
  animation: blink 1s infinite;
}

// 渐变背景动画
.gradient-animate {
  background: linear-gradient(-45deg, $color-primary, $color-primary-light-3, $color-primary-light-6, $color-primary-light-9);
  background-size: 400% 400%;
  animation: gradientShift 4s ease infinite;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
  background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

// 波纹效果
.ripple {
  position: relative;
  overflow: hidden;
  
  &::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
  }
  
  &:active::before {
    width: 300px;
    height: 300px;
  }
}

// 进度条动画
.progress-animate {
  .progress-bar {
    position: relative;
    overflow: hidden;
    
    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
      );
      background-size: 50px 50px;
      animation: progressStripes 1s linear infinite;
    }
  }
}

@keyframes progressStripes {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 50px 0;
  }
}